﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using Gift.DAL;
using Gift.Model;


namespace WebSite.admin.order
{
    public partial class sendOrderPrinter : BaseAdmin
    {
        string _orderCode = string.Empty;
        string _receiver = string.Empty;
        string _receiverPhone = string.Empty;
        string _receiverAddress = string.Empty;
        string _remark = string.Empty;

        public string Remark
        {
            get { return _remark; }
            set { _remark = value; }
        }

        DALCardOrderFile theCardOrderFile = new DALCardOrderFile();

        StringBuilder _sbGoodsList = new StringBuilder();

        public StringBuilder SbGoodsList
        {
            get { return _sbGoodsList; }
            set { _sbGoodsList = value; }
        }

        public string ReceiverAddress
        {
            get { return _receiverAddress; }
            set { _receiverAddress = value; }
        }

        public string ReceiverPhone
        {
            get { return _receiverPhone; }
            set { _receiverPhone = value; }
        }

        public string Receiver
        {
            get { return _receiver; }
            set { _receiver = value; }
        }

        public string PrintDate
        {
            get { return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); }
        }

        public string OrderCode
        {
            get { return _orderCode; }
            set { _orderCode = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.BuildForm();
            }

        }
        void BuildForm()
        {
            DataTable table = theCardOrderFile.GetList(string.Format(" orderCode='{0}' ", Request.QueryString["code"])).Tables[0];
            int i = 1;
            foreach (DataRow dr in table.Rows)
            {
                if (i == 1)
                {
                    _orderCode = dr["orderCode"].ToString();
                    _receiver = dr["receiver"].ToString();
                    _receiverPhone = dr["receiverPhone"].ToString();
                    _receiverAddress = dr["receiverAddress"].ToString();
                    _remark = dr["remark"].ToString();
                   

                }
                this._sbGoodsList.AppendFormat("<tr><td>{0}</td><td class='goods_con'>{1}</td><td>{2}</td></tr>"
                                     , i.ToString()
                                      , dr["goodsName"].ToString()
                                      , dr["goodsCount"].ToString()
                                      );
                i++;
            }
        }
    }
}